package com.ken.common.web.config;

import com.ken.common.web.async.AsyncExecurityConfiguration;
import com.ken.common.web.exception.GlobalException;
import com.ken.common.web.utils.ApplicationContextUtils;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * Web模块的自动配置类 - SpringBoot的自动装配功能 (SpringBoot = SpringIOC + 自动装配)
 */
@Configuration
@ComponentScan("com.ken.business")
@EnableDiscoveryClient
public class WebAutoConfiguration {

    /**
     * 配置全局异常处理器
     * @return
     */
    @Bean
    public GlobalException getGlobalException(){
        return new GlobalException();
    }

    /**
     * Spring容器的工具类
     * @return
     */
    @Bean
    public ApplicationContextUtils getApplicationContextUtils(){
        return new ApplicationContextUtils();
    }


    /**
     * 线程池配套的配置类
     * @return
     */
    @Bean
    public AsyncExecurityConfiguration getAsyncExecurityConfiguration(){
        return new AsyncExecurityConfiguration();
    }
}
